package com.card.client.dialog;

import com.card.client.entry.ViewObject;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;

public class DeleteDialog extends DialogBox {

	private static DeleteDialogUiBinder uiBinder = GWT
			.create(DeleteDialogUiBinder.class);

	interface DeleteDialogUiBinder extends UiBinder<Widget, DeleteDialog> {
	}

	@UiField Button submit;

	@UiField Button cancel;
	
	@UiField HorizontalPanel  des;
	
	private ViewObject viewObject;
	
	private Long id;
	
	public DeleteDialog(String title, String text, ViewObject viewObject, Long id) {
		setWidget(uiBinder.createAndBindUi(this));
		setGlassEnabled(true);
		setAnimationEnabled(true);
		setModal(true);
		center();
		this.viewObject = viewObject;
		this.id = id;
		setTitle("删除" + title);
		setText("删除" + title);
		des.add(new HTML(text));
		submit.setText("确认");
		cancel.setText("取消");
	}

	@UiHandler("submit")
	void onClickSubmit(ClickEvent e) {
		viewObject.delDate(id);
		hide();
	}
	
	@UiHandler("cancel")
	void onClickCancel(ClickEvent e) {
		hide();
	}

}
